package com.quark.framework.database;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.quark.framework.configuration.QuarkConfigManager;
import com.quark.framework.utility.QuarkLog;

public class QuarkDBExecuterFactory {
	private static QuarkDBExecuterFactory inst = new QuarkDBExecuterFactory();
	private QuarkDBExecuteManager transactionFreeManager = new QuarkDBExecuteManager();
	private QuarkDBExecuteManager transactionSafeManager = new QuarkDBExecuteManager();
	
	public static QuarkDBExecuterFactory getInstance()
	{
		return inst;
	}
	
	public QuarkDBExecuteManager getExecuteManager(boolean transactionSupported)
	{
		if(transactionSupported)
			return transactionSafeManager;
		else
			return transactionFreeManager;
	}
	
	public boolean init()
	{		
		if(QuarkDBConnectionPool.getInstance().init())
			return false;
		
		QuarkDBMetaDataManager metaManager = new QuarkDBMetaDataManager();
		metaManager.init(QuarkDBConnectionPool.getInstance().getMetaData());

		if(transactionSafeManager.init(metaManager))
			return false;
		
		if(transactionSafeManager.init(metaManager))
			return false;
		
		return true;
	}
	
}
